package com.example.coursaccino;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class StudentBrowsePage extends Activity {
	
	final Context context = this;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
        setContentView(R.layout.student_browse);
        
        // If 'OK' button is clicked
        Button okButton = (Button) this.findViewById(R.id.okButton);
        okButton.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
            	//Intent intent = getIntent();
        		EditText input = (EditText)findViewById(R.id.searchCourse);
        		String searchInput = input.getText().toString();
        		
        		// GET SEARCH RESULTS FROM DATABASE
        		
        		AlertDialog.Builder courseAdded = new AlertDialog.Builder(context);
         
        			// set title
        			courseAdded.setTitle("Course Added!");
         
        			// set dialog message
        			courseAdded
        				.setMessage("What do you want to do now?")
        				.setCancelable(false)
        				.setPositiveButton("View My Courses",new DialogInterface.OnClickListener() {
        					public void onClick(DialogInterface dialog,int id) {
        						// if this button is clicked, go to view courses page
        						Intent openNewPage = new Intent(StudentBrowsePage.this, StudentViewPage.class); 
        		                StudentBrowsePage.this.startActivity(openNewPage); 
        					}
        				  })
        				.setNegativeButton("Back To Browsing Courses",new DialogInterface.OnClickListener() {
        					public void onClick(DialogInterface dialog,int id) {
        						// if this button is clicked, just close the dialog box
        						dialog.cancel();
        					}
        				});
         
        				// create alert dialog
        				AlertDialog courseAddedDialog = courseAdded.create();
         
        				// show it
        				courseAddedDialog.show();
                //Intent openNewPage = new Intent(StudentBrowsePage.this, StudentShowResults.class); 
                //StudentMainPage.this.startActivity(openNewPage); 
            }
        });
		
	}
	
//	@Override
//    public boolean onCreateOptionsMenu(Menu menu) {
//        getMenuInflater().inflate(R.menu.activity_main, menu);
//        return true;
//    }

}
